use corrupt1.dta
*generate the time variable
gen tm = m(2013-9) + _n - 1
format tm %tm
tsset tm 



* HP filter
tsfilter hp income = income, trend(income_t)  gain(income_g income_f)
twoway (line income tm)  (line income_t tm) (line income_g tm) (line income_f tm)

tsfilter hp cost = cost, trend(cost_t)  gain(cost_g cost_f)
twoway (line cost tm)  (line cost_t tm) (line cost_g tm) (line cost_f tm)

tsfilter hp manage = manage, trend(manage_t)  gain(manage_g manage_f)
twoway (line manage tm)  (line manage_t tm) (line manage_g tm) (line manage_f tm)

tsfilter hp punish = punish, trend(punish_t)  gain(punish_g punish_f)
twoway (line punish tm)  (line punish_t tm) (line punish_g tm) (line punish_f tm)

twoway (line adj_income tm ) (line adj_cost tm) (line adj_manage tm) (line adj_punish tm)

  
  
* vec model and impulse responses for adjust variables
varsoc adj_punish adj_income adj_cost adj_manage

vecrank adj_punish adj_income adj_cost adj_manage

vec adj_punish adj_income adj_cost adj_manage

vec adj_punish adj_income adj_cost adj_manage 
  irf create vec1, set(vec01, replace) step(20)
  irf graph oirf, impulse(adj_punish) response(adj_income)
  irf graph oirf, impulse(adj_punish) response(adj_cost)
  irf graph oirf, impulse(adj_punish) response(adj_manage)
  irf graph oirf, impulse(adj_cost) response(adj_punish)

 dfuller punish,drift
 dfuller income,drift
 dfuller cost,drift
 dfuller manage,drift
 varsoc  income cost manage punish
 var  income cost manage punish, lag(2) dfk small 
   est store var1
 esttab var1 
 irf create var1, set(var01, replace) step(50)
  irf graph oirf, impulse(punish) response(income)
  irf graph oirf, impulse(punish) response(cost)
  irf graph oirf, impulse(punish) response(manage)
varstable,graph dlabel
 graph combine G1.gph G2.gph G3.gph G4.gph
 
 
* vec model and impulse responses for real variables
varsoc punish income cost manage

vecrank punish income cost manage,lag(5)

vec punish income cost manage

vec punish income cost manage
  irf create vec1, set(vec01, replace) step(50)
  irf graph oirf, impulse(punish) response(income)
  irf graph oirf, impulse(punish) response(cost)
  irf graph oirf, impulse(punish) response(manage)
varstable,graph dlabel

gen lnpuni = ln(punish)
gen lnincome = ln(income)
gen lncost = ln(cost)
gen lnmanage = ln(manage)

varsoc lnpuni lnincome lncost lnmanage
*vecrank lnpuni lnincome lncost lnmanage,lag(2)

vec lnpuni lnincome lncost lnmanage

vec lnpuni lnincome lncost lnmanage
  irf create vec1, set(vec01, replace) step(50)
  irf graph oirf, impulse(lnpuni) response(lnincome)
  irf graph oirf, impulse(lnpuni) response(lncost)
  irf graph oirf, impulse(lnpuni) response(lnmanage)
  irf graph oirf, impulse(lnpuni) response(adj_punish)
